import React from 'react';
import ReactDOM from 'react-dom';
import Home from '@/components/home/index.js';
import Detail from '@/components/detail/index.js';
import Register from '@/components/register/index.js';
import Login from '@/components/login/index.js';
import * as serviceWorker from './serviceWorker';
import { Provider } from 'react-redux';
import store from './store/index';
import { HashRouter as Router, Route, Redirect, Switch } from 'react-router-dom';
import './main.scss';
const fn = ()=>{
  ReactDOM.render(
    <Router>
      <Provider store = { store }>
        <Switch>
        <Route path = '/home' component = { Home } />
        <Route path = '/register' component = { Register } />
        <Route path = '/login' component = { Login } />
        <Route path = '/detail/:id' component = { Detail } />
        <Redirect to={ {pathname: '/home'} } />
        </Switch>
      </Provider>
    </Router>
    , document.getElementById('root'));
}
fn()
store.subscribe(fn)

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: http://bit.ly/CRA-PWA
serviceWorker.unregister();
